using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.Universal;
using UnityEngine.Serialization;

public class CameraHeightRendererFeature : ScriptableRendererFeature
{
    [System.Serializable]
    public class Settings
    {
        public RenderPassEvent m_RenderPassEvent = RenderPassEvent.AfterRenderingOpaques;
        public Material m_BlitMaterial = null;
        [FormerlySerializedAs("m_renderTexture")] public RenderTexture m_RenderTexture = null;
    }

    public Settings m_Settings = new Settings();
    private CameraHeightRenderPass m_blitPass;

    public override void Create()
    {
        m_blitPass = new CameraHeightRenderPass("CameraHeight", m_Settings);
    }

    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        if (null == m_Settings.m_BlitMaterial)
        {
            Debug.LogError("丢失Blit材质");
            return;
        }

        m_blitPass.renderPassEvent = m_Settings.m_RenderPassEvent;
        m_blitPass.Setup(renderer);
        renderer.EnqueuePass(m_blitPass);
    }
}
